'''
Read in an edge list and prepend all node id's with their cluster info.  Ex:

	1	2
	1	3
	1	5
	
Result:
	cluster1/1	cluster1/2
	cluster1/1	cluster2/3
	...
	
'''

import os, sys

def getClusterMapping(filename):
	
	file = open(filename, 'r')
	
	clusterMappings = {}
	for line in file:
		tuple = line.strip().split('\t')
		clusterMappings[tuple[0]] = tuple[1]
		
	return clusterMappings

if __name__ == '__main__':
	
	clusterMappings = getClusterMapping(sys.argv[1])
	
	edgeFile = open(sys.argv[2], 'r')
	modifiedEdgeFile = open(sys.argv[2] + '.mod', 'w')
	
	for line in edgeFile:
		edges = line.strip().split('\t')
		
		modifiedEdgeFile.write(clusterMappings[edges[0]] + '/' + edges[0] + '\t' + clusterMappings[edges[1]] + '/' + edges[1] + '\n')
	
	pass